﻿using AJWPFAdmin.Core.Models;
using AJWPFAdmin.Core.Utils;
using AJWPFAdmin.Services.EF;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AJWPFAdmin.Services.Models
{
    public class CarIdentificationConfigExt
    {
        public static CarIdentificationConfig GetCarIdentificationConfig(DbService db)
        {
            var cfgJson = db.SystemConfigDictionaries
                    .Where(p => p.Key == Core.Enums.SystemConfigKey.CarIdentificationConfig)
                    .Select(p => p.StringValue).FirstOrDefault();

            return CommonUtil.TryGetJSONObject<CarIdentificationConfig>(cfgJson)
                ?? new CarIdentificationConfig() { Type = CarIdentificationConfig.StoreType.本地 };
        }
    }
}
